package cn.stylefeng.guns.modular.tool.service.impl;

import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.core.util.ExcelWrite;
import cn.stylefeng.guns.modular.tool.entity.ToolExpressReconciliationZtx;
import cn.stylefeng.guns.modular.tool.mapper.ToolExpressReconciliationZtxMapper;
import cn.stylefeng.guns.modular.tool.model.params.ToolExpressReconciliationHtInstallParam;
import cn.stylefeng.guns.modular.tool.model.params.ToolExpressReconciliationMkyInstallParam;
import cn.stylefeng.guns.modular.tool.model.params.ToolExpressReconciliationRfParam;
import cn.stylefeng.guns.modular.tool.model.params.ToolExpressReconciliationYfInstallParam;
import cn.stylefeng.guns.modular.tool.model.params.ToolExpressReconciliationYmInstallParam;
import cn.stylefeng.guns.modular.tool.model.params.ToolExpressReconciliationYqbInstallParam;
import cn.stylefeng.guns.modular.tool.model.params.ToolExpressReconciliationYtInstallParam;
import cn.stylefeng.guns.modular.tool.model.params.ToolExpressReconciliationZtxInstallParam;
import cn.stylefeng.guns.modular.tool.model.params.ToolExpressReconciliationZtxParam;
import cn.stylefeng.guns.modular.tool.model.result.ToolExpressReconciliationHtInstallResult;
import cn.stylefeng.guns.modular.tool.model.result.ToolExpressReconciliationMkyInstallResult;
import cn.stylefeng.guns.modular.tool.model.result.ToolExpressReconciliationYfInstallResult;
import cn.stylefeng.guns.modular.tool.model.result.ToolExpressReconciliationYmInstallResult;
import cn.stylefeng.guns.modular.tool.model.result.ToolExpressReconciliationYqbInstallResult;
import cn.stylefeng.guns.modular.tool.model.result.ToolExpressReconciliationYtInstallResult;
import cn.stylefeng.guns.modular.tool.model.result.ToolExpressReconciliationZtxInstallResult;
import cn.stylefeng.guns.modular.tool.model.result.ToolExpressReconciliationZtxResult;
import cn.stylefeng.guns.modular.tool.service.ToolExpressReconciliationHtInstallService;
import cn.stylefeng.guns.modular.tool.service.ToolExpressReconciliationMkyInstallService;
import cn.stylefeng.guns.modular.tool.service.ToolExpressReconciliationRfService;
import cn.stylefeng.guns.modular.tool.service.ToolExpressReconciliationYfInstallService;
import cn.stylefeng.guns.modular.tool.service.ToolExpressReconciliationYmInstallService;
import cn.stylefeng.guns.modular.tool.service.ToolExpressReconciliationYqbInstallService;
import cn.stylefeng.guns.modular.tool.service.ToolExpressReconciliationYtInstallService;
import cn.stylefeng.guns.modular.tool.service.ToolExpressReconciliationZtxInstallService;
import  cn.stylefeng.guns.modular.tool.service.ToolExpressReconciliationZtxService;
import cn.stylefeng.guns.sys.modular.system.entity.User;
import cn.stylefeng.guns.sys.modular.system.service.UserService;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.roses.core.util.ToolUtil;

/**
 * <p>
 * 中通对账管理新 服务实现类
 * </p>
 *
 * @author zhucx
 * @since 2023-05-30
 */
@Service
public class ToolExpressReconciliationZtxServiceImpl extends ServiceImpl<ToolExpressReconciliationZtxMapper, ToolExpressReconciliationZtx> implements ToolExpressReconciliationZtxService {

    @Override
    public void add(ToolExpressReconciliationZtxParam param){
        ToolExpressReconciliationZtx entity = getEntity(param);
        this.save(entity);
    }

    @Override
    public void delete(ToolExpressReconciliationZtxParam param){
        this.removeById(getKey(param));
    }

    @Override
    public void update(ToolExpressReconciliationZtxParam param){
        ToolExpressReconciliationZtx oldEntity = getOldEntity(param);
        ToolExpressReconciliationZtx newEntity = getEntity(param);
        ToolUtil.copyProperties(newEntity, oldEntity);
        this.updateById(newEntity);
    }

    @Override
    public ToolExpressReconciliationZtxResult findBySpec(ToolExpressReconciliationZtxParam param){
        return null;
    }

    @Override
    public List<ToolExpressReconciliationZtxResult> findListBySpec(ToolExpressReconciliationZtxParam param){
        return this.baseMapper.findListBySpec(param);
    }

    @Override
    public LayuiPageInfo findPageBySpec(ToolExpressReconciliationZtxParam param,String condition,Long operateId){
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.customPageList(pageContext, param,condition,operateId);
        return LayuiPageFactory.createPageInfo(page);
    }

    @Override
    public LayuiPageInfo findPageBySpecZtxDz(ToolExpressReconciliationZtxParam param,String condition){
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.findPageBySpecZtxDz(pageContext, param,condition);
        return LayuiPageFactory.createPageInfo(page);
    }

    private Serializable getKey(ToolExpressReconciliationZtxParam param){
        return param.getId();
    }

    private Page getPageContext() {
        return LayuiPageFactory.defaultPage();
    }

    private ToolExpressReconciliationZtx getOldEntity(ToolExpressReconciliationZtxParam param) {
        return this.getById(getKey(param));
    }

    private ToolExpressReconciliationZtx getEntity(ToolExpressReconciliationZtxParam param) {
        ToolExpressReconciliationZtx entity = new ToolExpressReconciliationZtx();
        ToolUtil.copyProperties(param, entity);
        return entity;
    }
    
    @Resource
    private UserService userService;

    @Autowired
    private ToolExpressReconciliationZtxInstallService toolExpressReconciliationZtxInstallService;

    @Resource
    private ToolExpressReconciliationRfService toolExpressReconciliationRfService;

    @Resource
    private ToolExpressReconciliationYfInstallService toolExpressReconciliationYfInstallService;

    @Resource
    private ToolExpressReconciliationHtInstallService toolExpressReconciliationHtInstallService;

    @Resource
    private ToolExpressReconciliationYqbInstallService toolExpressReconciliationYqbInstallService;

    @Resource
    private ToolExpressReconciliationYtInstallService toolExpressReconciliationYtInstallService;

    @Resource
    private ToolExpressReconciliationMkyInstallService toolExpressReconciliationMkyInstallService;

    @Resource
    private ToolExpressReconciliationYmInstallService toolExpressReconciliationYmInstallService;

	@Override
	public ResponseData getExceldata(MultipartFile file,Long reconciliationId, ResponseData data) throws IOException{
		String fileName = file.getOriginalFilename();
		
		User user = userService.getcurrentUser();

    	BigDecimal as = new BigDecimal("0");
    	BigDecimal qj05 = new BigDecimal("0.5");
    	BigDecimal yi = new BigDecimal("1");
    	BigDecimal yidwu = new BigDecimal("1.5");
    	BigDecimal er = new BigDecimal("2");
    	BigDecimal san = new BigDecimal("3");
    	BigDecimal si = new BigDecimal("4");
    	BigDecimal wu = new BigDecimal("5");
    	BigDecimal wuder = new BigDecimal("5.2");
    	BigDecimal wudwu = new BigDecimal("5.5");
		
		List<ToolExpressReconciliationZtxParam> ztxlist = new ArrayList<ToolExpressReconciliationZtxParam>();
		List<ToolExpressReconciliationRfParam> rflist = new ArrayList<ToolExpressReconciliationRfParam>();
        
		ToolExpressReconciliationZtxInstallParam ztxInstallParam = new ToolExpressReconciliationZtxInstallParam();
		ztxInstallParam.setCustomerName("快递成本");
		ztxInstallParam.setDeptId(user.getDeptId());
        List<ToolExpressReconciliationZtxInstallResult> ztxi = toolExpressReconciliationZtxInstallService.findListBySpec(ztxInstallParam,user.getOperateId());//中通报价

        ToolExpressReconciliationYtInstallParam ytInstallParam = new ToolExpressReconciliationYtInstallParam();
        ytInstallParam.setDeptId(user.getDeptId());
        ytInstallParam.setCustomerName("娥英素水收入");
        List<ToolExpressReconciliationYtInstallResult> ytizz = toolExpressReconciliationYtInstallService.findListBySpec(ytInstallParam,user.getOperateId());//圆通报价娥英素水
        
        ztxInstallParam.setCustomerName("济南柏川收入");
        List<ToolExpressReconciliationZtxInstallResult> ztxisg = toolExpressReconciliationZtxInstallService.findListBySpec(ztxInstallParam,user.getOperateId());//济南柏川
        
        ToolExpressReconciliationYfInstallParam expressReconciliationYfInstallParam = new ToolExpressReconciliationYfInstallParam();
        expressReconciliationYfInstallParam.setDeptId(user.getDeptId());
        List<ToolExpressReconciliationYfInstallResult> rfi = toolExpressReconciliationYfInstallService.findListBySpec(expressReconciliationYfInstallParam,user.getOperateId());//软风报价
        
        ToolExpressReconciliationHtInstallParam htInstallParam = new ToolExpressReconciliationHtInstallParam();
        htInstallParam.setDeptId(user.getDeptId());
        List<ToolExpressReconciliationHtInstallResult> hti = toolExpressReconciliationHtInstallService.findListBySpec(htInstallParam,user.getOperateId());//华图报价

        ToolExpressReconciliationYqbInstallParam yqbInstallParam = new ToolExpressReconciliationYqbInstallParam();
        yqbInstallParam.setDeptId(user.getDeptId());
        List<ToolExpressReconciliationYqbInstallResult> yqbi = toolExpressReconciliationYqbInstallService.findListBySpec(yqbInstallParam, user.getOperateId());//一起吧报价

        ToolExpressReconciliationMkyInstallParam mkyInstallParam = new ToolExpressReconciliationMkyInstallParam();
        mkyInstallParam.setDeptId(user.getDeptId());
        List<ToolExpressReconciliationMkyInstallResult> mkyi = toolExpressReconciliationMkyInstallService.findListBySpec(mkyInstallParam, user.getOperateId());//麦凯盈报价
        
        ToolExpressReconciliationYmInstallParam ymInstallParam = new ToolExpressReconciliationYmInstallParam();
        ymInstallParam.setDeptId(user.getDeptId());
        List<ToolExpressReconciliationYmInstallResult> ymi = toolExpressReconciliationYmInstallService.findListBySpec(ymInstallParam, user.getOperateId());//医美物料报价

        ytInstallParam.setCustomerName("风灵露收入");
        List<ToolExpressReconciliationYtInstallResult> flli = toolExpressReconciliationYtInstallService.findListBySpec(ytInstallParam,user.getOperateId());//风灵露收入

		if (!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) {
			data.setMessage("上传文件格式不正确");
			data.setSuccess(false);
			return data;
        }

		boolean isExcel2003 = true;
        if (fileName.matches("^.+\\.(?i)(xlsx)$")) {
            isExcel2003 = false;
        }
        InputStream is = file.getInputStream();
        Workbook wb = null;
        if (isExcel2003) {
            wb = new HSSFWorkbook(is);
        } else {
            wb = new XSSFWorkbook(is);
        }
        Sheet sheet = wb.getSheetAt(0);
        
        for (int r = 1; r <= sheet.getLastRowNum()+1; r++) {
        	Row row = sheet.getRow(r);
            if (row == null){
                continue;
            }
            
            ToolExpressReconciliationZtxParam ztxxx = new ToolExpressReconciliationZtxParam();//中通账单
            ztxxx.setReconciliationId(reconciliationId);
            
            ToolExpressReconciliationRfParam rfffParam = new ToolExpressReconciliationRfParam();//软风账单
            rfffParam.setV1("ztx");
            rfffParam.setReconciliationId(reconciliationId);


            String  orderNumber = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(0));//运单号码
            if (ToolUtil.isNotEmpty(orderNumber)) {
            	ztxxx.setOrderNumber(orderNumber);
            	rfffParam.setOrderNumber(orderNumber);
			} else {
				break;
			}

            String  jijianShijian = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(1));//寄件时间
            if (ToolUtil.isNotEmpty(jijianShijian)) {
            	ztxxx.setJijianShijian(jijianShijian.substring(0, 10));
			} 
            
            BigDecimal aWeight = new BigDecimal("0");//核算重量
            String aProvince = "";//核算省份

            String  shouprovince = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(2));//收件省份
            if (ToolUtil.isNotEmpty(shouprovince)) {
            	aProvince = shouprovince.replaceAll("省", "").replaceAll("市", "").replaceAll("壮族自治区", "").replaceAll("回族自治区", "").replaceAll("维吾尔自治区", "").replaceAll("自治区", "");
            	ztxxx.setProvince(shouprovince.replaceAll("省", "").replaceAll("市", "").replaceAll("壮族自治区", "").replaceAll("回族自治区", "").replaceAll("维吾尔自治区", "").replaceAll("自治区", ""));
            	ztxxx.setShouprovince(shouprovince);
			} 
            
            String  city = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(19));//市
            if (ToolUtil.isNotEmpty(city)) {
        		rfffParam.setCity(city);
    			if(city.equals("深圳市")||city.equals("深圳")) {
    				rfffParam.setRemarks("深圳");
    			}
            }

            String  settlementWeight = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(3));//计费重量
            if (ToolUtil.isNotEmpty(settlementWeight)) {
            	BigDecimal settlementWeightbig = new BigDecimal(settlementWeight).setScale(2, BigDecimal.ROUND_HALF_UP);
            	aWeight = settlementWeightbig;
            	ztxxx.setSettlementWeight(settlementWeightbig.toString());

				if(settlementWeightbig.compareTo(as) == 1 && settlementWeightbig.compareTo(qj05) != 1) {//0 -  0.5kg
					ztxxx.setWeightQj("0-0.5kg");
				}
				if(settlementWeightbig.compareTo(qj05) == 1 && settlementWeightbig.compareTo(yi) != 1) {//0 -  1kg
					ztxxx.setWeightQj("0.5-1kg");
				}
				if(settlementWeightbig.compareTo(yi) == 1 && settlementWeightbig.compareTo(er) != 1) {//1 -  2kg
					ztxxx.setWeightQj("1-2kg");
				}
				if(settlementWeightbig.compareTo(er) == 1 && settlementWeightbig.compareTo(san) != 1) {//2 -  3kg
					ztxxx.setWeightQj("2-3kg");
				}
				if(settlementWeightbig.compareTo(san) == 1) {//3kg以上
					ztxxx.setWeightQj("3kg以上");
				}
			} 

            String  firstWeight = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(4));//首重
            if (ToolUtil.isNotEmpty(firstWeight)) {
            	BigDecimal firstWeightbig = new BigDecimal(firstWeight).setScale(1, BigDecimal.ROUND_HALF_UP);
            	ztxxx.setFirstWeight(firstWeightbig.toString());
			} 

            String  cWeight = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(5));//续重
            if (ToolUtil.isNotEmpty(cWeight)) {
            	BigDecimal cWeightbig = new BigDecimal(cWeight).setScale(1, BigDecimal.ROUND_HALF_UP);
            	ztxxx.setCWeight(cWeightbig.toString());
			} 

            String  settlementExpenses = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(6));//快递费
            if (ToolUtil.isNotEmpty(settlementExpenses)) {
            	BigDecimal settlementExpensesbig = new BigDecimal(settlementExpenses).setScale(1, BigDecimal.ROUND_HALF_UP);
            	ztxxx.setSettlementExpenses(settlementExpensesbig.toString());
			} 
            
            String  ycProvince = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(18));//省  云仓省份
            if (ToolUtil.isNotEmpty(ycProvince)) {
            	if(ToolUtil.isEmpty(aProvince)) {
            		aProvince = ycProvince.replaceAll("省", "").replaceAll("市", "").replaceAll("壮族自治区", "").replaceAll("回族自治区", "").replaceAll("维吾尔自治区", "").replaceAll("自治区", "");
            	}
            	ztxxx.setYcProvince(ycProvince.replaceAll("省", "").replaceAll("市", "").replaceAll("壮族自治区", "").replaceAll("回族自治区", "").replaceAll("维吾尔自治区", "").replaceAll("自治区", ""));//云仓省份
    			if(ToolUtil.isNotEmpty(ztxxx.getProvince())) {
    				if(ztxxx.getProvince().equals(ztxxx.getYcProvince())) {
    					ztxxx.setProvinceTrue("true");
    				} else {
    					ztxxx.setProvinceTrue("false");
    				}
    			}
			}
            
            String  ycWeight = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(7));//云仓重量
            if (ToolUtil.isNotEmpty(ycWeight)) {
    			BigDecimal ycWeightbig = new BigDecimal(ycWeight).setScale(3, BigDecimal.ROUND_HALF_UP);
    			ztxxx.setYcWeight(ycWeightbig.toString());//云仓重量
    			
    			if(ToolUtil.isNotEmpty(ztxxx.getSettlementWeight())) {
                	BigDecimal settlementWeightbig = new BigDecimal(ztxxx.getSettlementWeight()).setScale(2, BigDecimal.ROUND_HALF_UP);
                	if(settlementWeightbig.compareTo(yi) != 1) {
                		ztxxx.setWeightQj2("1KG以下");
                	}
                	if(settlementWeightbig.compareTo(yi) == 1 && settlementWeightbig.compareTo(er) != 1) {
                		ztxxx.setWeightQj2("1-2KG");
                	}
                	if(settlementWeightbig.compareTo(er) == 1 && settlementWeightbig.compareTo(san) != 1) {
                		ztxxx.setWeightQj2("2-3KG");
                	}
                	if(settlementWeightbig.compareTo(san) == 1) {
                		ztxxx.setWeightQj2("3KG以上");
                	}
        			
    				BigDecimal weightChayi = settlementWeightbig.subtract(ycWeightbig).setScale(2,BigDecimal.ROUND_HALF_UP);
    				ztxxx.setWeightChayi(weightChayi.toString());//重量差异
    			} else {
    				aWeight = ycWeightbig;
                	if(ycWeightbig.compareTo(yi) != 1) {
                		ztxxx.setWeightQj2("1KG以下");
                	}
                	if(ycWeightbig.compareTo(yi) == 1 && ycWeightbig.compareTo(er) != 1) {
                		ztxxx.setWeightQj2("1-2KG");
                	}
                	if(ycWeightbig.compareTo(er) == 1 && ycWeightbig.compareTo(san) != 1) {
                		ztxxx.setWeightQj2("2-3KG");
                	}
                	if(ycWeightbig.compareTo(san) == 1) {
                		ztxxx.setWeightQj2("3KG以上");
                	}
    			}
            }

            String  customerName = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(8));//客户
            if (ToolUtil.isNotEmpty(customerName)) {
            	ztxxx.setCustomerName(customerName);
            	rfffParam.setCustomerName(customerName);
			} else {
				ztxxx.setCustomerName("无");
            	rfffParam.setCustomerName("无");
			}
            
            if(aWeight.compareTo(as) == 1 && ToolUtil.isNotEmpty(aProvince)) {
            	ztxxx.setRoundingWeightKg(aWeight.setScale( 0, BigDecimal.ROUND_UP ).longValue()+"");//取整重量
        		//匹配中通报价   计算核对邮费  计算邮费差异
    			for (ToolExpressReconciliationZtxInstallResult i : ztxi) {
    				if(aProvince.equals(i.getProvince())) {
    					if(aWeight.compareTo(as) == 1 && aWeight.compareTo(qj05) != 1) {//0 -  0.5kg
    						if(ToolUtil.isNotEmpty(i.getQj05g())) {
    							ztxxx.setPostageCheck(i.getQj05g());
    						}
    						break;
    					}
    					if(aWeight.compareTo(qj05) == 1 && aWeight.compareTo(yi) != 1) {//0.5 -  1kg
    						if(ToolUtil.isNotEmpty(i.getQj51kg())) {
    							ztxxx.setPostageCheck(i.getQj51kg());
    						}
    						break;
    					}
    					if(aWeight.compareTo(yi) == 1 && aWeight.compareTo(er) != 1) {//1 -  2kg
    						if(ToolUtil.isNotEmpty(i.getQj12kg())) {
    							ztxxx.setPostageCheck(i.getQj12kg());
    						}
    						break;
    					}
    					if(aWeight.compareTo(er) == 1 && aWeight.compareTo(san) != 1) {//2 -  3kg
    						if(ToolUtil.isNotEmpty(i.getQj23kg())) {
    							ztxxx.setPostageCheck(i.getQj23kg());
    						}
    						break;
    					}
    					if(aWeight.compareTo(san) == 1) {//3kg以上
							if(ToolUtil.isNotEmpty(i.getFirstWeight3kg()) && ToolUtil.isNotEmpty(i.getCWeight3kg())) {//续重*重量+首重
								ztxxx.setFirstWeight2(i.getFirstWeight3kg());
								ztxxx.setCWeight2(i.getCWeight3kg());
								BigDecimal firstWeight3kgbig = new BigDecimal(i.getFirstWeight3kg());//首重
								BigDecimal cWeight3kgbig = new BigDecimal(i.getCWeight3kg());//续重
								BigDecimal xmulz = cWeight3kgbig.multiply(aWeight).setScale(4, BigDecimal.ROUND_HALF_UP);//续重 *  重量
								BigDecimal addxmulz = xmulz.add(firstWeight3kgbig).setScale(4, BigDecimal.ROUND_HALF_UP);//续重*重量+首重
								ztxxx.setPostageCheck(addxmulz.toString());
							}
    						break;
    					}
    				}
    			}
            } else {
            	ztxxx.setPostageCheck("0");
            }
			if(ToolUtil.isNotEmpty(ztxxx.getSettlementExpenses())) {
				BigDecimal postageCheckbig = new BigDecimal(ztxxx.getPostageCheck()).setScale(4, BigDecimal.ROUND_HALF_UP);
				BigDecimal settlementExpensesbig = new BigDecimal(ztxxx.getSettlementExpenses()).setScale(1, BigDecimal.ROUND_HALF_UP);
				BigDecimal postageDifferencebig = settlementExpensesbig.subtract(postageCheckbig).setScale(4, BigDecimal.ROUND_HALF_UP);
				ztxxx.setPostageDifference(postageDifferencebig.toString());//总差异
			}
			
			ztxxx.setAdvanceCharge("-2.5");//预付款
			BigDecimal fu2dwu = new BigDecimal("-2.5");
            
            if(ToolUtil.isNotEmpty(ztxxx.getSettlementExpenses())) {//应付  =  合计结算费用 + 预付款
				BigDecimal settlementExpensesbig = new BigDecimal(ztxxx.getSettlementExpenses());
				BigDecimal copeWithbig = settlementExpensesbig.add(fu2dwu).setScale(2, BigDecimal.ROUND_HALF_UP);
				ztxxx.setCopeWith(copeWithbig.toString());
            } else {
            	if(ToolUtil.isNotEmpty(ztxxx.getPostageCheck())) {
            		BigDecimal postageCheckbig = new BigDecimal(ztxxx.getPostageCheck()).setScale(4, BigDecimal.ROUND_HALF_UP);
            		BigDecimal copeWithbig = postageCheckbig.add(fu2dwu).setScale(2, BigDecimal.ROUND_HALF_UP);
            		ztxxx.setCopeWith(copeWithbig.toString());
            	}
            }
            
            String  quantity = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(22));//数量
            if (ToolUtil.isNotEmpty(quantity)) {
            	ztxxx.setQuantity(quantity);//数量
        		rfffParam.setNums(quantity);//发货件数
            }
            
            String  outNumber = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(9));//出库单号
            if (ToolUtil.isNotEmpty(outNumber)) {
        		rfffParam.setOutNumber(outNumber);
            }
            
            String  shopNumber = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(10));//店铺编号
            if (ToolUtil.isNotEmpty(shopNumber)) {
        		rfffParam.setShopNumber(shopNumber);
            }
            
            String  shopName = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(11));//店铺名称
            if (ToolUtil.isNotEmpty(shopName)) {
        		rfffParam.setShopName(shopName);
            }
            
            String  platform = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(12));//平台站点
            if (ToolUtil.isNotEmpty(platform)) {
        		rfffParam.setPlatform(platform);
            }
            
            String  outWNumber = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(13));//出仓单号
            if (ToolUtil.isNotEmpty(outWNumber)) {
        		rfffParam.setOutWNumber(outWNumber);
            }
            
            String  inOrderNumber = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(14));//内部订单号
            if (ToolUtil.isNotEmpty(inOrderNumber)) {
        		rfffParam.setInOrderNumber(inOrderNumber);
            }
            
            String  outTime = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(15));//出库日期
            if (ToolUtil.isNotEmpty(outTime)) {
        		rfffParam.setOutTime(outTime);
            }
            
            String  states = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(16));//状态
            if (ToolUtil.isNotEmpty(states)) {
        		rfffParam.setStates(states);
            }
            
            String  expressName = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(17));//快递公司
            if (ToolUtil.isNotEmpty(expressName)) {
        		rfffParam.setExpressName(expressName);
            }
            
            String  provinces = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(18));//省
            if (ToolUtil.isNotEmpty(provinces)) {
        		rfffParam.setProvinces(provinces);
            }
            
            String  area = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(20));//区
            if (ToolUtil.isNotEmpty(area)) {
        		rfffParam.setArea(area);
        		if(rfffParam.getCustomerName().equals("软风2C")) {
        			if(area.equals("虎门镇")||area.equals("虎门港管委会")) {
        				rfffParam.setRemarks("虎门");
        			}
        		}
            }
            
            String  street = cn.stylefeng.guns.core.util.DateUtil.getCellValueByCell(row.getCell(21));//街道
            if (ToolUtil.isNotEmpty(street)) {
        		rfffParam.setStreet(street);
        		if(rfffParam.getCustomerName().equals("软风2C")) {
        			if(street.equals("虎门镇")) {
        				rfffParam.setRemarks("虎门");
        			}
        		}
            }

            if(ToolUtil.isNotEmpty(rfffParam.getCustomerName())) {
            	if(ToolUtil.isNotEmpty(rfffParam.getNums())) {
            		BigDecimal numsbig = new BigDecimal(rfffParam.getNums());
            		if(rfffParam.getCustomerName().equals("软风2C")) {
                		BigDecimal ldlliu = new BigDecimal("0.06");
                		BigDecimal ldwu = new BigDecimal("0.5");
            			//软风 打包发货费：5包及5包以下：0.5，5包以上:0.5+（X-5）*0.06  1元封顶
            			if(numsbig.compareTo(wu) != 1) {
            				rfffParam.setV2("0.5");
            			} else {
                    		BigDecimal numsbigsub = numsbig.subtract(wu);
							BigDecimal numsbigsubmul = numsbigsub.multiply(ldlliu);
							BigDecimal v2s = numsbigsubmul.add(ldwu).setScale(8, BigDecimal.ROUND_HALF_UP);
							if(v2s.compareTo(yi) == 1) {
								rfffParam.setV2("1");
							} else {
								rfffParam.setV2(v2s.toString());
							}
            			}
            		}
            		if(rfffParam.getCustomerName().equals("华图图书")) {
            			//华图：0.6+（X-1）*0.1  1元封顶
                		BigDecimal ldyi = new BigDecimal("0.1");
                		BigDecimal ldliu = new BigDecimal("0.6");
                		BigDecimal numsbigsub = numsbig.subtract(yi);
						BigDecimal numsbigsubmul = numsbigsub.multiply(ldyi);
						BigDecimal v2s = numsbigsubmul.add(ldliu).setScale(8, BigDecimal.ROUND_HALF_UP);
						if(v2s.compareTo(yi) == 1) {
							rfffParam.setV2("1");
						} else {
							rfffParam.setV2(v2s.toString());
						}
            		}
            		if(rfffParam.getCustomerName().equals("娥英素水")) {
            			//娥英素水：0.4+（X-1）*0.1，不封顶
                		BigDecimal ldyi = new BigDecimal("0.1");
                		BigDecimal ldsi = new BigDecimal("0.4");
                		BigDecimal numsbigsub = numsbig.subtract(yi);
						BigDecimal numsbigsubmul = numsbigsub.multiply(ldyi);
						BigDecimal v2s = numsbigsubmul.add(ldsi).setScale(8, BigDecimal.ROUND_HALF_UP);
						rfffParam.setV2(v2s.toString());
            		}
            		if(rfffParam.getCustomerName().equals("济南柏川")) {
            			//济南柏川：操作费1件0.6元，0.8元封顶
                		BigDecimal ldliu = new BigDecimal("0.6");
                		BigDecimal ldba = new BigDecimal("0.8");
						BigDecimal v2s = numsbig.multiply(ldliu);
						if(v2s.compareTo(ldba) == 1) {
							rfffParam.setV2("0.8");
						} else {
							rfffParam.setV2(v2s.toString());
						}
            		}
            		if(rfffParam.getCustomerName().equals("金通钰达")) {
            			//金童钰达，一单1.5元
						rfffParam.setV2("1.5");
            		}
            		if(rfffParam.getCustomerName().equals("鲁梦源")) {
            			//鲁梦源：0.3元/单
						rfffParam.setV2("0.3");
            		}
            	}
        		BigDecimal chargingWeightKg = new BigDecimal("0");//核算重量
        		if(ToolUtil.isNotEmpty(ztxxx.getSettlementWeight())&&ToolUtil.isNotEmpty(ztxxx.getYcWeight())) {
        			BigDecimal ycWeightbig = new BigDecimal(ztxxx.getYcWeight()).setScale(3, BigDecimal.ROUND_HALF_UP);
                	BigDecimal settlementWeightbig = new BigDecimal(ztxxx.getSettlementWeight()).setScale(2, BigDecimal.ROUND_HALF_UP);
        			if(ycWeightbig.compareTo(settlementWeightbig) == 1) {
        				chargingWeightKg = ycWeightbig;
        			} else {
        				chargingWeightKg = settlementWeightbig;
        			}
        		} else {
        			if(aWeight.compareTo(as) == 1) {
        				chargingWeightKg = aWeight;
        			}
        		}

        		if(chargingWeightKg.compareTo(as) == 1 && ToolUtil.isNotEmpty(aProvince)) {
    				if(chargingWeightKg.compareTo(as) == 1 && chargingWeightKg.compareTo(qj05) != 1) {//0 -  0.5kg
    					rfffParam.setWeightQj("0-0.5kg");
    				}
    				if(chargingWeightKg.compareTo(qj05) == 1 && chargingWeightKg.compareTo(yi) != 1) {//0 -  1kg
    					rfffParam.setWeightQj("0-1kg");
    				}
    				if(chargingWeightKg.compareTo(yi) == 1 && chargingWeightKg.compareTo(er) != 1) {//1 -  2kg
    					rfffParam.setWeightQj("1-2kg");
    				}
    				if(chargingWeightKg.compareTo(er) == 1 && chargingWeightKg.compareTo(san) != 1) {//2 -  3kg
    					rfffParam.setWeightQj("2-3kg");
    				}
    				if(chargingWeightKg.compareTo(san) == 1) {//3kg以上
    					rfffParam.setWeightQj("3kg以上");
    				}
        			rfffParam.setProvince(aProvince);//省份
        			rfffParam.setChargingWeightKg(chargingWeightKg.toString());//计费重量
    				rfffParam.setRoundingWeightKg(chargingWeightKg.setScale( 0, BigDecimal.ROUND_UP ).longValue()+"");//取整重量
        			
                	if(rfffParam.getCustomerName().equals("软风2C")) {
                		BigDecimal sumExpressMoney = new BigDecimal("0");//总快递费
                		String provincestr = "";
                		if(ToolUtil.isNotEmpty(rfffParam.getRemarks())) {
                			provincestr = rfffParam.getRemarks();
                		} else {
                			provincestr = rfffParam.getProvince();
                		}
                		for (ToolExpressReconciliationYfInstallResult i : rfi) {
    						if(provincestr.equals(i.getDestination())) {
    							if(provincestr.equals("海南")||provincestr.equals("新疆")||provincestr.equals("西藏")) {
    								if(ToolUtil.isNotEmpty(i.getUnilateralism()) && ToolUtil.isNotEmpty(i.getCWeight())) {
    									BigDecimal unilateralismrf = new BigDecimal(i.getUnilateralism());//面单费
    									BigDecimal cCWeight = new BigDecimal(i.getCWeight());//续重
    									BigDecimal wmulcCWeight = chargingWeightKg.multiply(cCWeight);//重量*续重
    									BigDecimal expressMoney = unilateralismrf.add(wmulcCWeight).setScale(8, BigDecimal.ROUND_HALF_UP);//面单费+（重量*续重）
    									sumExpressMoney = expressMoney;
    									rfffParam.setUnilateralism(unilateralismrf.toString());
    									rfffParam.setCWeight(cCWeight.toString());
    									rfffParam.setExpressMoney(expressMoney.toString());//快递费
    								}
    							} else {
                					if(chargingWeightKg.compareTo(as) == 1 && chargingWeightKg.compareTo(yi) != 1) {//0 - 1kg
                						if(ToolUtil.isNotEmpty(i.getQj01kg())) {
        									rfffParam.setExpressMoney(i.getQj01kg());//快递费
        									BigDecimal qj01kg = new BigDecimal(i.getQj01kg());
        									sumExpressMoney = qj01kg;
                						}
                					}
                					if(chargingWeightKg.compareTo(yi) == 1 && chargingWeightKg.compareTo(er) != 1) {//1 - 2kg
                						if(ToolUtil.isNotEmpty(i.getQj12kg())) {
        									rfffParam.setExpressMoney(i.getQj12kg());//快递费
        									BigDecimal qj12kg = new BigDecimal(i.getQj12kg());
        									sumExpressMoney = qj12kg;
                						}
                					}
                					if(chargingWeightKg.compareTo(er) == 1 && chargingWeightKg.compareTo(san) != 1) {//2 - 3kg
                						if(ToolUtil.isNotEmpty(i.getQj23kg())) {
        									rfffParam.setExpressMoney(i.getQj23kg());//快递费
        									BigDecimal qj23kg = new BigDecimal(i.getQj23kg());
        									sumExpressMoney = qj23kg;
                						}
                					}
                					if(chargingWeightKg.compareTo(san) == 1) {//3kg以上
        								if(ToolUtil.isNotEmpty(i.getUnilateralism()) && ToolUtil.isNotEmpty(i.getCWeight())) {
        									BigDecimal unilateralismrf = new BigDecimal(i.getUnilateralism());//面单费
        									BigDecimal cCWeight = new BigDecimal(i.getCWeight());//续重
        									BigDecimal wmulcCWeight = chargingWeightKg.multiply(cCWeight);//重量*续重
        									BigDecimal expressMoney = unilateralismrf.add(wmulcCWeight).setScale(8, BigDecimal.ROUND_HALF_UP);//面单费+（重量*续重）
        									sumExpressMoney = expressMoney;
        									rfffParam.setUnilateralism(unilateralismrf.toString());
        									rfffParam.setCWeight(cCWeight.toString());
        									rfffParam.setExpressMoney(expressMoney.toString());//快递费
        								}
                					}
    							}
    							if(ToolUtil.isNotEmpty(i.getAdditional())) {//地区加收
    								BigDecimal additional = new BigDecimal(i.getAdditional());
    								BigDecimal wmuladditional = chargingWeightKg.multiply(additional).setScale(4, BigDecimal.ROUND_HALF_UP);//重量*地区加收
    								rfffParam.setAdditional(wmuladditional.toString());
    								sumExpressMoney = sumExpressMoney.add(wmuladditional);
    							}
    							if(ToolUtil.isNotEmpty(i.getStandard()) && ToolUtil.isNotEmpty(i.getMinimum())) {//中转费
    								rfffParam.setStandard(i.getStandard());
    								rfffParam.setMinimum(i.getMinimum());
    								BigDecimal standard = new BigDecimal(i.getStandard());//二三级中转标准
    								BigDecimal minimum = new BigDecimal(i.getMinimum());//二三级中转最低
    								BigDecimal wmulstandard = standard.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);//二三级中转标准*重量
    								//如果  二三级中转标准*重量 > 二三级中转最低 就用二三级中转标准*重量 作为中转费，不然就用二三级中转最低作为中转费
    								if(wmulstandard.compareTo(minimum) == 1) {
    									rfffParam.setTransferMoney(wmulstandard.toString());
    									sumExpressMoney = sumExpressMoney.add(wmulstandard);
    								} else {
    									rfffParam.setTransferMoney(i.getMinimum());
    									sumExpressMoney = sumExpressMoney.add(minimum);
    								}
    							}
    							if(chargingWeightKg.compareTo(wudwu) == 1) {//5.5kg以上
    								if(ToolUtil.isNotEmpty(i.getZz55above())) {//5.5Kg以上的中转费
    									BigDecimal zz55above = new BigDecimal(i.getZz55above());
    									BigDecimal wmulzz55above = zz55above.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
    									rfffParam.setTransferMoney(wmulzz55above.toString());
    									sumExpressMoney = sumExpressMoney.add(wmulzz55above);
    								}
    							}
    							rfffParam.setSumExpressMoney(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//总快递费
    							ztxxx.setIncome(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//收入
    							break;
    						}
    					}
                		rflist.add(rfffParam);
                	}
                	if(rfffParam.getCustomerName().equals("华图图书")) {
                		BigDecimal sumExpressMoney = new BigDecimal("0");//总快递费
                		String provincestr = rfffParam.getProvince();
                		if(ToolUtil.isNotEmpty(rfffParam.getCity())) {
                			if(rfffParam.getCity().indexOf("凉山") == 0) {
                				provincestr = "四川凉山";
                			}
                			if(rfffParam.getCity().indexOf("甘孜") == 0) {
                				provincestr = "四川甘孜";
                			}
                			if(rfffParam.getCity().indexOf("阿坝") == 0) {
                				provincestr = "四川阿坝";
                			}
                			if(rfffParam.getCity().indexOf("包头") == 0) {
                				provincestr = "内蒙包头中心";
                			}
                		} 

                		for (ToolExpressReconciliationHtInstallResult i : hti) {
    						if(provincestr.equals(i.getProvince())) {
            					if(chargingWeightKg.compareTo(as) == 1 && chargingWeightKg.compareTo(yi) != 1) {//0 - 1kg
            						if(ToolUtil.isNotEmpty(i.getQj01kg())) {
    									rfffParam.setExpressMoney(i.getQj01kg());//快递费
    									BigDecimal qj01kg = new BigDecimal(i.getQj01kg());
    									sumExpressMoney = qj01kg;
            						}
            					}
            					if(chargingWeightKg.compareTo(yi) == 1 && chargingWeightKg.compareTo(er) != 1) {//1 - 2kg
            						if(ToolUtil.isNotEmpty(i.getQj12kg())) {
    									rfffParam.setExpressMoney(i.getQj12kg());//快递费
    									BigDecimal qj12kg = new BigDecimal(i.getQj12kg());
    									sumExpressMoney = qj12kg;
            						}
            					}
            					if(chargingWeightKg.compareTo(er) == 1 && chargingWeightKg.compareTo(san) != 1) {//2 - 3kg
            						if(ToolUtil.isNotEmpty(i.getQj23kg())) {
    									rfffParam.setExpressMoney(i.getQj23kg());//快递费
    									BigDecimal qj23kg = new BigDecimal(i.getQj23kg());
    									sumExpressMoney = qj23kg;
            						}
            					}
            					if(chargingWeightKg.compareTo(san) == 1 && chargingWeightKg.compareTo(si) != 1) {//3 - 4kg
            						if(ToolUtil.isNotEmpty(i.getQj34kg())) {
    									rfffParam.setExpressMoney(i.getQj34kg());//快递费
    									BigDecimal qj34kg = new BigDecimal(i.getQj34kg());
    									sumExpressMoney = qj34kg;
            						}
            					}
            					if(chargingWeightKg.compareTo(si) == 1) {//4kg以上
        							if(ToolUtil.isNotEmpty(i.getFirstWeight4kg()) && ToolUtil.isNotEmpty(i.getCWeight())) {//首重+（续重*重量）
        								rfffParam.setFirstWeight(i.getFirstWeight4kg());
        								rfffParam.setCWeight(i.getCWeight());
        								BigDecimal firstWeight4kg = new BigDecimal(i.getFirstWeight4kg());//首重
        								BigDecimal cWeight2 = new BigDecimal(i.getCWeight());//续重
        								BigDecimal xmulz = cWeight2.multiply(chargingWeightKg).setScale(8, BigDecimal.ROUND_HALF_UP);//续重 *  重量
        								BigDecimal addxmulz = firstWeight4kg.add(xmulz).setScale(8, BigDecimal.ROUND_HALF_UP);//首重+（续重*重量）
        								rfffParam.setExpressMoney(addxmulz.toString());//快递费
    									sumExpressMoney = addxmulz;
        							}
            					}
    							rfffParam.setSumExpressMoney(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//总快递费
    							ztxxx.setIncome(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//收入
    							break;
    						}
    					}
                		rflist.add(rfffParam);
                	}
                	if(rfffParam.getCustomerName().equals("娥英素水")) {
                		BigDecimal sumExpressMoney = new BigDecimal("0");//总快递费
            			for (ToolExpressReconciliationYtInstallResult i : ytizz) {
            				if(rfffParam.getProvince().equals(i.getProvince())) {
            					if(chargingWeightKg.compareTo(as) == 1 && chargingWeightKg.compareTo(qj05) != 1) {//0 -  0.5kg
            						if(ToolUtil.isNotEmpty(i.getQj05g())) {
            							rfffParam.setExpressMoney(i.getQj05g());
    									BigDecimal qj05g = new BigDecimal(i.getQj05g());
    									sumExpressMoney = qj05g;
            						}
            						if(ToolUtil.isNotEmpty(i.getAdditional())) {
            							BigDecimal additionalbig = new BigDecimal(i.getAdditional()).setScale(2, BigDecimal.ROUND_HALF_UP);
            							BigDecimal tesujiashou2big = additionalbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
            							sumExpressMoney = sumExpressMoney.add(tesujiashou2big).setScale(4, BigDecimal.ROUND_HALF_UP);
            			            	rfffParam.setAdditionalSpecial(tesujiashou2big.toString());
            						}
            					}
            					if(chargingWeightKg.compareTo(qj05) == 1 && chargingWeightKg.compareTo(yi) != 1) {//0.5 -  1kg
            						if(ToolUtil.isNotEmpty(i.getQj51kg())) {
            							rfffParam.setExpressMoney(i.getQj51kg());
    									BigDecimal qj51kg = new BigDecimal(i.getQj51kg());
    									sumExpressMoney = qj51kg;
            						}
            						if(ToolUtil.isNotEmpty(i.getAdditional())) {
            							BigDecimal additionalbig = new BigDecimal(i.getAdditional()).setScale(2, BigDecimal.ROUND_HALF_UP);
            							BigDecimal tesujiashou2big = additionalbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
            							sumExpressMoney = sumExpressMoney.add(tesujiashou2big).setScale(4, BigDecimal.ROUND_HALF_UP);
            			            	rfffParam.setAdditionalSpecial(tesujiashou2big.toString());
            						}
            					}
            					if(chargingWeightKg.compareTo(yi) == 1 && chargingWeightKg.compareTo(er) != 1) {//1 -  2kg
            						if(ToolUtil.isNotEmpty(i.getQj12kg())) {
            							rfffParam.setExpressMoney(i.getQj12kg());
    									BigDecimal qj12kg = new BigDecimal(i.getQj12kg());
    									sumExpressMoney = qj12kg;
            						}
            						if(ToolUtil.isNotEmpty(i.getAdditional())) {
            							BigDecimal additionalbig = new BigDecimal(i.getAdditional()).setScale(2, BigDecimal.ROUND_HALF_UP);
            							BigDecimal tesujiashou2big = additionalbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
            							sumExpressMoney = sumExpressMoney.add(tesujiashou2big).setScale(4, BigDecimal.ROUND_HALF_UP);
            			            	rfffParam.setAdditionalSpecial(tesujiashou2big.toString());
            						}
            					}
            					if(chargingWeightKg.compareTo(er) == 1 && chargingWeightKg.compareTo(san) != 1) {//2 -  3kg
            						if(ToolUtil.isNotEmpty(i.getQj23kg())) {
            							rfffParam.setExpressMoney(i.getQj23kg());
    									BigDecimal qj23kg = new BigDecimal(i.getQj23kg());
    									sumExpressMoney = qj23kg;
            						}
            						if(ToolUtil.isNotEmpty(i.getAdditional())) {
            							BigDecimal additionalbig = new BigDecimal(i.getAdditional()).setScale(2, BigDecimal.ROUND_HALF_UP);
            							BigDecimal tesujiashou2big = additionalbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
            							sumExpressMoney = sumExpressMoney.add(tesujiashou2big).setScale(4, BigDecimal.ROUND_HALF_UP);
            			            	rfffParam.setAdditionalSpecial(tesujiashou2big.toString());
            						}
            					}
            					if(chargingWeightKg.compareTo(san) == 1) {//3kg以上
        							if(ToolUtil.isNotEmpty(i.getUnilateralism()) && ToolUtil.isNotEmpty(i.getCWeight3kg())) {//续重*重量+面单费
        								rfffParam.setCWeight(i.getCWeight3kg());
        								rfffParam.setUnilateralism(i.getUnilateralism());
        								BigDecimal unilateralismbig = new BigDecimal(i.getUnilateralism());//面单费
        								BigDecimal cWeight3kgbig = new BigDecimal(i.getCWeight3kg());//续重
        								BigDecimal xmulz = cWeight3kgbig.multiply(chargingWeightKg).setScale(8, BigDecimal.ROUND_HALF_UP);//续重 *  重量
        								BigDecimal addxmulz = xmulz.add(unilateralismbig).setScale(8, BigDecimal.ROUND_HALF_UP);//续重*重量+面单费
            							rfffParam.setExpressMoney(addxmulz.toString());
    									sumExpressMoney = addxmulz;
        							}
            						if(ToolUtil.isNotEmpty(i.getAdditional())) {
            							BigDecimal additionalbig = new BigDecimal(i.getAdditional()).setScale(2, BigDecimal.ROUND_HALF_UP);
            							BigDecimal tesujiashou2big = additionalbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
            							sumExpressMoney = sumExpressMoney.add(tesujiashou2big).setScale(4, BigDecimal.ROUND_HALF_UP);
            			            	rfffParam.setAdditionalSpecial(tesujiashou2big.toString());
            						}
            					}
    							rfffParam.setSumExpressMoney(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//总快递费
    							ztxxx.setIncome(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//收入
    							break;
            				}
            			}
                		rflist.add(rfffParam);
                	}
                	if(rfffParam.getCustomerName().equals("济南柏川")) {
                		BigDecimal sumExpressMoney = new BigDecimal("0");//总快递费
            			for (ToolExpressReconciliationZtxInstallResult i : ztxisg) {
            				if(rfffParam.getProvince().equals(i.getProvince())) {
            					if(chargingWeightKg.compareTo(as) == 1 && chargingWeightKg.compareTo(qj05) != 1) {//0 -  0.5kg
            						if(ToolUtil.isNotEmpty(i.getQj05g())) {
            							rfffParam.setExpressMoney(i.getQj05g());
            						}
            						break;
            					}
            					if(chargingWeightKg.compareTo(qj05) == 1 && chargingWeightKg.compareTo(yi) != 1) {//0.5 -  1kg
            						if(ToolUtil.isNotEmpty(i.getQj51kg())) {
            							rfffParam.setExpressMoney(i.getQj51kg());
            						}
            						break;
            					}
            					if(chargingWeightKg.compareTo(yi) == 1 && chargingWeightKg.compareTo(er) != 1) {//1 -  2kg
            						if(ToolUtil.isNotEmpty(i.getQj12kg())) {
            							rfffParam.setExpressMoney(i.getQj12kg());
            						}
            						break;
            					}
            					if(chargingWeightKg.compareTo(er) == 1 && chargingWeightKg.compareTo(san) != 1) {//2 -  3kg
            						if(ToolUtil.isNotEmpty(i.getQj23kg())) {
            							rfffParam.setExpressMoney(i.getQj23kg());
            						}
            						break;
            					}
            					if(chargingWeightKg.compareTo(san) == 1 && chargingWeightKg.compareTo(wuder) != 1) {//3kg以上
        							if(ToolUtil.isNotEmpty(i.getFirstWeight3kg()) && ToolUtil.isNotEmpty(i.getCWeight3kg())) {//续重*重量+首重
        								rfffParam.setFirstWeight(i.getFirstWeight3kg());
        								rfffParam.setCWeight(i.getCWeight3kg());
        								BigDecimal firstWeight3kgbig = new BigDecimal(i.getFirstWeight3kg());//首重
        								BigDecimal cWeight3kgbig = new BigDecimal(i.getCWeight3kg());//续重
        								BigDecimal xmulz = cWeight3kgbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);//续重 *  重量
        								BigDecimal addxmulz = xmulz.add(firstWeight3kgbig).setScale(4, BigDecimal.ROUND_HALF_UP);//续重*重量+首重
        								rfffParam.setExpressMoney(addxmulz.toString());
        							}
            						break;
            					}
    							break;
            				}
            			}
            			if(ToolUtil.isNotEmpty(rfffParam.getExpressMoney())) {
							BigDecimal expressMoney = new BigDecimal(rfffParam.getExpressMoney());
							sumExpressMoney = sumExpressMoney.add(expressMoney).setScale(8, BigDecimal.ROUND_HALF_UP);
							rfffParam.setSumExpressMoney(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//总快递费
							ztxxx.setIncome(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//收入
            			}
                		rflist.add(rfffParam);
                	}
                	if(rfffParam.getCustomerName().equals("金通钰达")) {
                		BigDecimal sumExpressMoney = new BigDecimal("0");//总快递费
                		if(chargingWeightKg.compareTo(san) != 1) {//3公斤以内
                			rfffParam.setExpressMoney("4");
                			sumExpressMoney = si;
                		}
                		if(chargingWeightKg.compareTo(san) == 1) {//大于3公斤的运费  =  （重量-3）*1.5
                			BigDecimal subchargingWeightKg = chargingWeightKg.subtract(san).setScale(3, BigDecimal.ROUND_HALF_UP);//重量  -  3
                			BigDecimal mulyidwu = subchargingWeightKg.multiply(yidwu).setScale(8, BigDecimal.ROUND_HALF_UP);//*1.5
                			BigDecimal mulyidwuaddsi = si.add(mulyidwu).setScale(8, BigDecimal.ROUND_HALF_UP);
                			rfffParam.setExpressMoney(mulyidwuaddsi.toString());
                			sumExpressMoney = mulyidwuaddsi;
                		}
						rfffParam.setSumExpressMoney(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//总快递费
						ztxxx.setIncome(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//收入
                		rflist.add(rfffParam);
                	}
                	if(rfffParam.getCustomerName().equals("一起吧")) {
                		BigDecimal sumExpressMoney = new BigDecimal("0");//总快递费
            			for (ToolExpressReconciliationYqbInstallResult i : yqbi) {
            				if(rfffParam.getProvince().equals(i.getProvince())) {
            					if(chargingWeightKg.compareTo(as) == 1 && chargingWeightKg.compareTo(yi) != 1) {//0 -  1kg
            						if(ToolUtil.isNotEmpty(i.getQj01kg())) {
            							rfffParam.setExpressMoney(i.getQj01kg());
    									BigDecimal qj01kg = new BigDecimal(i.getQj01kg());
    									sumExpressMoney = qj01kg;
            						}
            						if(ToolUtil.isNotEmpty(i.getAdditional())) {
            							BigDecimal additionalbig = new BigDecimal(i.getAdditional()).setScale(2, BigDecimal.ROUND_HALF_UP);
            							BigDecimal tesujiashou2big = additionalbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
            							sumExpressMoney = sumExpressMoney.add(tesujiashou2big).setScale(4, BigDecimal.ROUND_HALF_UP);
            			            	rfffParam.setAdditionalSpecial(tesujiashou2big.toString());
            						}
            					}
            					if(chargingWeightKg.compareTo(yi) == 1 && chargingWeightKg.compareTo(er) != 1) {//1 -  2kg
            						if(ToolUtil.isNotEmpty(i.getQj12kg())) {
            							rfffParam.setExpressMoney(i.getQj12kg());
    									BigDecimal qj12kg = new BigDecimal(i.getQj12kg());
    									sumExpressMoney = qj12kg;
            						}
            						if(ToolUtil.isNotEmpty(i.getAdditional())) {
            							BigDecimal additionalbig = new BigDecimal(i.getAdditional()).setScale(2, BigDecimal.ROUND_HALF_UP);
            							BigDecimal tesujiashou2big = additionalbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
            							sumExpressMoney = sumExpressMoney.add(tesujiashou2big).setScale(4, BigDecimal.ROUND_HALF_UP);
            			            	rfffParam.setAdditionalSpecial(tesujiashou2big.toString());
            						}
            					}
            					if(chargingWeightKg.compareTo(er) == 1 && chargingWeightKg.compareTo(san) != 1) {//2 -  3kg
            						if(ToolUtil.isNotEmpty(i.getQj23kg())) {
            							rfffParam.setExpressMoney(i.getQj23kg());
    									BigDecimal qj23kg = new BigDecimal(i.getQj23kg());
    									sumExpressMoney = qj23kg;
            						}
            						if(ToolUtil.isNotEmpty(i.getAdditional())) {
            							BigDecimal additionalbig = new BigDecimal(i.getAdditional()).setScale(2, BigDecimal.ROUND_HALF_UP);
            							BigDecimal tesujiashou2big = additionalbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
            							sumExpressMoney = sumExpressMoney.add(tesujiashou2big).setScale(4, BigDecimal.ROUND_HALF_UP);
            			            	rfffParam.setAdditionalSpecial(tesujiashou2big.toString());
            						}
            					}
            					if(chargingWeightKg.compareTo(san) == 1) {//3kg以上
        							if(ToolUtil.isNotEmpty(i.getUnilateralism()) && ToolUtil.isNotEmpty(i.getCWeight3kg())) {//续重*重量+面单费
        								rfffParam.setCWeight(i.getCWeight3kg());
        								rfffParam.setUnilateralism(i.getUnilateralism());
        								BigDecimal unilateralismbig = new BigDecimal(i.getUnilateralism());//面单费
        								BigDecimal cWeight3kgbig = new BigDecimal(i.getCWeight3kg());//续重
        								BigDecimal xmulz = cWeight3kgbig.multiply(chargingWeightKg).setScale(8, BigDecimal.ROUND_HALF_UP);//续重 *  重量
        								BigDecimal addxmulz = xmulz.add(unilateralismbig).setScale(8, BigDecimal.ROUND_HALF_UP);//续重*重量+面单费
            							rfffParam.setExpressMoney(addxmulz.toString());
    									sumExpressMoney = addxmulz;
        							}
            						if(ToolUtil.isNotEmpty(i.getAdditional())) {
            							BigDecimal additionalbig = new BigDecimal(i.getAdditional()).setScale(2, BigDecimal.ROUND_HALF_UP);
            							BigDecimal tesujiashou2big = additionalbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
            							sumExpressMoney = sumExpressMoney.add(tesujiashou2big).setScale(4, BigDecimal.ROUND_HALF_UP);
            			            	rfffParam.setAdditionalSpecial(tesujiashou2big.toString());
            						}
            					}
    							rfffParam.setSumExpressMoney(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//总快递费
    							ztxxx.setIncome(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//收入
    							break;
            				}
            			}
                		rflist.add(rfffParam);
                	}
                	if(rfffParam.getCustomerName().equals("麦凯盈")) {
                		BigDecimal sumExpressMoney = new BigDecimal("0");//总快递费
            			for (ToolExpressReconciliationMkyInstallResult i : mkyi) {
            				if(rfffParam.getProvince().equals(i.getProvince())) {
            					if(chargingWeightKg.compareTo(as) == 1 && chargingWeightKg.compareTo(yi) != 1) {//0 -  1kg
            						if(ToolUtil.isNotEmpty(i.getQj01g())) {
            							rfffParam.setExpressMoney(i.getQj01g());
    									BigDecimal qj01kg = new BigDecimal(i.getQj01g());
    									sumExpressMoney = qj01kg;
            						}
            					}
            					if(chargingWeightKg.compareTo(yi) == 1 && chargingWeightKg.compareTo(er) != 1) {//1 -  2kg
            						if(ToolUtil.isNotEmpty(i.getQj12kg())) {
            							rfffParam.setExpressMoney(i.getQj12kg());
    									BigDecimal qj12kg = new BigDecimal(i.getQj12kg());
    									sumExpressMoney = qj12kg;
            						}
            					}
            					if(chargingWeightKg.compareTo(er) == 1 && chargingWeightKg.compareTo(san) != 1) {//2 -  3kg
            						if(ToolUtil.isNotEmpty(i.getQj23kg())) {
            							rfffParam.setExpressMoney(i.getQj23kg());
    									BigDecimal qj23kg = new BigDecimal(i.getQj23kg());
    									sumExpressMoney = qj23kg;
            						}
            					}
            					if(chargingWeightKg.compareTo(san) == 1) {//3kg以上
        							if(ToolUtil.isNotEmpty(i.getUnilateralism()) && ToolUtil.isNotEmpty(i.getCWeight3kg())) {//续重*重量+面单费
        								rfffParam.setCWeight(i.getCWeight3kg());
        								rfffParam.setUnilateralism(i.getUnilateralism());
        								BigDecimal unilateralismbig = new BigDecimal(i.getUnilateralism());//面单费
        								BigDecimal cWeight3kgbig = new BigDecimal(i.getCWeight3kg());//续重
        								BigDecimal xmulz = cWeight3kgbig.multiply(chargingWeightKg).setScale(8, BigDecimal.ROUND_HALF_UP);//续重 *  重量
        								BigDecimal addxmulz = xmulz.add(unilateralismbig).setScale(8, BigDecimal.ROUND_HALF_UP);//续重*重量+面单费
            							rfffParam.setExpressMoney(addxmulz.toString());
    									sumExpressMoney = addxmulz;
        							}
            					}
    							rfffParam.setSumExpressMoney(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//总快递费
    							ztxxx.setIncome(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//收入
    							break;
            				}
            			}
                		rflist.add(rfffParam);
                	}
                	if(rfffParam.getCustomerName().equals("医美物料")) {
                		BigDecimal sumExpressMoney = new BigDecimal("0");//总快递费
            			for (ToolExpressReconciliationYmInstallResult i : ymi) {
            				if(rfffParam.getProvince().equals(i.getProvince())) {
            					if(chargingWeightKg.compareTo(as) == 1 && chargingWeightKg.compareTo(qj05) != 1) {//0 -  0.5kg
            						if(ToolUtil.isNotEmpty(i.getQj05kg())) {
            							rfffParam.setExpressMoney(i.getQj05kg());
    									BigDecimal qj05kg = new BigDecimal(i.getQj05kg());
    									sumExpressMoney = qj05kg;
            						}
            						if(ToolUtil.isNotEmpty(i.getAdditional())) {
            							BigDecimal additionalbig = new BigDecimal(i.getAdditional()).setScale(2, BigDecimal.ROUND_HALF_UP);
            							BigDecimal tesujiashou2big = additionalbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
            							sumExpressMoney = sumExpressMoney.add(tesujiashou2big).setScale(8, BigDecimal.ROUND_HALF_UP);
            			            	rfffParam.setAdditionalSpecial(tesujiashou2big.toString());
            						}
            					}
            					if(chargingWeightKg.compareTo(qj05) == 1 && chargingWeightKg.compareTo(yi) != 1) {//0.5 -  1kg
            						if(ToolUtil.isNotEmpty(i.getQj51kg())) {
            							rfffParam.setExpressMoney(i.getQj51kg());
    									BigDecimal qj51kg = new BigDecimal(i.getQj51kg());
    									sumExpressMoney = qj51kg;
            						}
            						if(ToolUtil.isNotEmpty(i.getAdditional())) {
            							BigDecimal additionalbig = new BigDecimal(i.getAdditional()).setScale(2, BigDecimal.ROUND_HALF_UP);
            							BigDecimal tesujiashou2big = additionalbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
            							sumExpressMoney = sumExpressMoney.add(tesujiashou2big).setScale(8, BigDecimal.ROUND_HALF_UP);
            			            	rfffParam.setAdditionalSpecial(tesujiashou2big.toString());
            						}
            					}
            					if(chargingWeightKg.compareTo(yi) == 1 && chargingWeightKg.compareTo(er) != 1) {//1 -  2kg
            						if(ToolUtil.isNotEmpty(i.getQj12kg())) {
            							rfffParam.setExpressMoney(i.getQj12kg());
    									BigDecimal qj12kg = new BigDecimal(i.getQj12kg());
    									sumExpressMoney = qj12kg;
            						}
            						if(ToolUtil.isNotEmpty(i.getAdditional())) {
            							BigDecimal additionalbig = new BigDecimal(i.getAdditional()).setScale(2, BigDecimal.ROUND_HALF_UP);
            							BigDecimal tesujiashou2big = additionalbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
            							sumExpressMoney = sumExpressMoney.add(tesujiashou2big).setScale(8, BigDecimal.ROUND_HALF_UP);
            			            	rfffParam.setAdditionalSpecial(tesujiashou2big.toString());
            						}
            					}
            					if(chargingWeightKg.compareTo(er) == 1 && chargingWeightKg.compareTo(san) != 1) {//2 -  3kg
            						if(ToolUtil.isNotEmpty(i.getQj23kg())) {
            							rfffParam.setExpressMoney(i.getQj23kg());
    									BigDecimal qj23kg = new BigDecimal(i.getQj23kg());
    									sumExpressMoney = qj23kg;
            						}
            						if(ToolUtil.isNotEmpty(i.getAdditional())) {
            							BigDecimal additionalbig = new BigDecimal(i.getAdditional()).setScale(2, BigDecimal.ROUND_HALF_UP);
            							BigDecimal tesujiashou2big = additionalbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
            							sumExpressMoney = sumExpressMoney.add(tesujiashou2big).setScale(8, BigDecimal.ROUND_HALF_UP);
            			            	rfffParam.setAdditionalSpecial(tesujiashou2big.toString());
            						}
            					}
            					if(chargingWeightKg.compareTo(san) == 1) {//3kg以上
        							if(ToolUtil.isNotEmpty(i.getUnilateralism()) && ToolUtil.isNotEmpty(i.getCWeight())) {//续重*重量+面单费
        								rfffParam.setCWeight(i.getCWeight());
        								rfffParam.setUnilateralism(i.getUnilateralism());
        								BigDecimal unilateralismbig = new BigDecimal(i.getUnilateralism());//面单费
        								BigDecimal cWeight3kgbig = new BigDecimal(i.getCWeight());//续重
        								BigDecimal xmulz = cWeight3kgbig.multiply(chargingWeightKg).setScale(8, BigDecimal.ROUND_HALF_UP);//续重 *  重量
        								BigDecimal addxmulz = xmulz.add(unilateralismbig).setScale(8, BigDecimal.ROUND_HALF_UP);//续重*重量+面单费
            							rfffParam.setExpressMoney(addxmulz.toString());
    									sumExpressMoney = addxmulz;
        							}
            						if(ToolUtil.isNotEmpty(i.getAdditional())) {
            							BigDecimal additionalbig = new BigDecimal(i.getAdditional()).setScale(2, BigDecimal.ROUND_HALF_UP);
            							BigDecimal tesujiashou2big = additionalbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);
            							sumExpressMoney = sumExpressMoney.add(tesujiashou2big).setScale(8, BigDecimal.ROUND_HALF_UP);
            			            	rfffParam.setAdditionalSpecial(tesujiashou2big.toString());
            						}
            					}
    							rfffParam.setSumExpressMoney(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//总快递费
    							ztxxx.setIncome(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//收入
    							break;
            				}
            			}
                		rflist.add(rfffParam);
                	}
                	if(rfffParam.getCustomerName().equals("风灵露")) {
                		BigDecimal sumExpressMoney = new BigDecimal("0");//总快递费
            			for (ToolExpressReconciliationYtInstallResult i : flli) {
            				if(rfffParam.getProvince().equals(i.getProvince())) {
            					if(chargingWeightKg.compareTo(as) == 1 && chargingWeightKg.compareTo(qj05) != 1) {//0 -  0.5kg
            						if(ToolUtil.isNotEmpty(i.getQj05g())) {
            							rfffParam.setExpressMoney(i.getQj05g());
            						}
            						break;
            					}
            					if(chargingWeightKg.compareTo(qj05) == 1 && chargingWeightKg.compareTo(yi) != 1) {//0.5 -  1kg
            						if(ToolUtil.isNotEmpty(i.getQj51kg())) {
            							rfffParam.setExpressMoney(i.getQj51kg());
            						}
            						break;
            					}
            					if(chargingWeightKg.compareTo(yi) == 1 && chargingWeightKg.compareTo(er) != 1) {//1 -  2kg
            						if(ToolUtil.isNotEmpty(i.getQj12kg())) {
            							rfffParam.setExpressMoney(i.getQj12kg());
            						}
            						break;
            					}
            					if(chargingWeightKg.compareTo(er) == 1 && chargingWeightKg.compareTo(san) != 1) {//2 -  3kg
            						if(ToolUtil.isNotEmpty(i.getQj23kg())) {
            							rfffParam.setExpressMoney(i.getQj23kg());
            						}
            						break;
            					}
            					if(chargingWeightKg.compareTo(san) == 1) {//3kg以上
        							if(ToolUtil.isNotEmpty(i.getUnilateralism()) && ToolUtil.isNotEmpty(i.getCWeight3kg())) {//续重*重量+首重
        								rfffParam.setUnilateralism(i.getUnilateralism());
        								rfffParam.setCWeight(i.getCWeight3kg());
        								BigDecimal Unilateralismbig = new BigDecimal(i.getUnilateralism());//首重
        								BigDecimal cWeight3kgbig = new BigDecimal(i.getCWeight3kg());//续重
        								BigDecimal xmulz = cWeight3kgbig.multiply(chargingWeightKg).setScale(4, BigDecimal.ROUND_HALF_UP);//续重 *  重量
        								BigDecimal addxmulz = xmulz.add(Unilateralismbig).setScale(4, BigDecimal.ROUND_HALF_UP);//续重*重量+首重
        								rfffParam.setExpressMoney(addxmulz.toString());
        							}
            						break;
            					}
    							break;
            				}
            			}
            			if(ToolUtil.isNotEmpty(rfffParam.getExpressMoney())) {
							BigDecimal expressMoney = new BigDecimal(rfffParam.getExpressMoney());
							sumExpressMoney = sumExpressMoney.add(expressMoney).setScale(8, BigDecimal.ROUND_HALF_UP);
							rfffParam.setSumExpressMoney(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//总快递费
							ztxxx.setIncome(sumExpressMoney.setScale(8, BigDecimal.ROUND_HALF_UP).toString());//收入
            			}
                		rflist.add(rfffParam);
                	}
        		}
            }

            if(ToolUtil.isNotEmpty(rfffParam.getSumExpressMoney())) {
            	BigDecimal Postagebig = new BigDecimal("0");//实收邮资
            	if(ToolUtil.isNotEmpty(ztxxx.getSettlementExpenses())) {
            		Postagebig = new BigDecimal(ztxxx.getSettlementExpenses()).setScale(3,BigDecimal.ROUND_HALF_UP);
            	} else {
            		if(ToolUtil.isNotEmpty(ztxxx.getPostageCheck())) {
                		Postagebig = new BigDecimal(ztxxx.getPostageCheck()).setScale(4,BigDecimal.ROUND_HALF_UP);
            		}
            	}
            	
            	BigDecimal sumExpressMoney = new BigDecimal(rfffParam.getSumExpressMoney());//总快递费
            	BigDecimal profit = sumExpressMoney.subtract(Postagebig).setScale(4,BigDecimal.ROUND_HALF_UP);//总快递费  -  总邮资 = 利润
            	ztxxx.setProfit(profit.toString());//利润
            }
            
            ztxlist.add(ztxxx);
        }
        if(ztxlist.size() > 0) {
        	this.saveBatchList(ztxlist);
        }
        if(rflist.size() > 0) {
        	toolExpressReconciliationRfService.saveBatchList(rflist);
        }
		return ResponseData.success();
	}

	@Override
	public Workbook exportToExcel(Long reconciliationId) {
	    //这是表头
	    String[] arr = {"运单编号","寄件时间","省份","收件省份","计费重量"," 快递重量区间","首重","续重","快递费"
	    		,"云仓省份","省份差异","云仓重量","重量差异","客户","取整重量"," 备注","核对快递费","首重","续重","运费差异"
	    		,"快递收入","利润","云仓重量区间","数量","预付款","应付"};
	    //这是具体数据
	    List<List<String>> list = new ArrayList<>();
	    
	    ToolExpressReconciliationZtxParam param = new ToolExpressReconciliationZtxParam();
	    param.setReconciliationId(reconciliationId);
	    List<ToolExpressReconciliationZtxResult> datalist = this.findListBySpec(param);
	    for (ToolExpressReconciliationZtxResult r : datalist) {
		    List<String> list1 = new ArrayList<String>();
		    list1.add(r.getOrderNumber());
		    list1.add(r.getJijianShijian());
		    list1.add(r.getProvince());
		    list1.add(r.getShouprovince());
		    list1.add(r.getSettlementWeight());
		    list1.add(r.getWeightQj());
		    list1.add(r.getFirstWeight());
		    list1.add(r.getCWeight());
		    list1.add(r.getSettlementExpenses());
		    
		    list1.add(r.getYcProvince());
		    list1.add(r.getProvinceTrue());
		    list1.add(r.getYcWeight());
		    list1.add(r.getWeightChayi());
		    list1.add(r.getCustomerName());
		    list1.add(r.getRoundingWeightKg());
		    list1.add(r.getRemarks());
		    list1.add(r.getPostageCheck());
		    list1.add(r.getFirstWeight2());
		    list1.add(r.getCWeight2());
		    list1.add(r.getPostageDifference());
		    list1.add(r.getIncome());
		    list1.add(r.getProfit());
		    list1.add(r.getWeightQj2());
		    list1.add(r.getQuantity());
		    list1.add(r.getAdvanceCharge());
		    list1.add(r.getCopeWith());
		    list.add(list1);
		}
	    return ExcelWrite.writeToExcelByList(arr, list);
	}

	@Override
	public void deleteBySpec(ToolExpressReconciliationZtxParam toolExpressReconciliationZtxParam) {
		this.baseMapper.deleteBySpec(toolExpressReconciliationZtxParam);
	}

	@Override
	public boolean saveBatchList(List<ToolExpressReconciliationZtxParam> list) {
		return this.baseMapper.saveBatchList(list);
	}

}
